package test.pcs;

import com.payment.lc.pcs.client.wrap.bo.ProductionChannelAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionTimeAttributes;
import com.payment.lc.pcs.client.wrap.model.ZiGuanTime;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.service.api.DynamicDataService;
import com.payment.lc.pcs.service.api.ProductionService;
import com.payment.lc.pcs.service.api.fund.JMFundService;
import com.payment.lc.pcs.service.api.modify.InterestRateService;
import com.payment.lc.pcs.service.api.modify.PcsChannelService;
import com.payment.lc.pcs.service.domain.*;
import com.payment.lc.pcs.service.request.InterestRateImportRequest;
import com.payment.lc.pcs.service.response.BaseResponse;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import test.BaseTest;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created on 2016/8/8.
 */
public class Demo3PcsRevisionTest2 extends BaseTest {

    @Autowired
    ProductionService productionService;

    @Autowired
    JMFundService jmFundService;

    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    InterestRateService interestRateService;

    @Autowired
    DynamicDataService dynamicDataService;

    @Autowired
    PcsChannelService pcsChannelService;

    @Test
    public void test() {
        test5();
    }

    static String prodCode = "17120013";
//    static String prodCode = "JM000509";
//    static String prodCode = "ZG0001";

    void test3() {
        Production production = productionWrapService.getProduction(prodCode);
        display(production.getCurrentDynamicInfo());
    }

    void test4() {
        display(dynamicDataService.getProductionSellInfo(prodCode));
        YueGuJiaoProduction yueGuJiao = productionService.getYueGuJiao(prodCode);
        display(yueGuJiao);

        Production production = productionService.getProduction(prodCode);
        display(production);

        ProductionTimeAttributes timeAttributes = productionWrapService.getProductionTimeAttributes(production);
        display(timeAttributes);

        ZiGuanTime ziGuanPeriod = productionWrapService.getZiGuanPeriod(production, new Date());
        display(ziGuanPeriod);

    }

    void test2() {

        FundsProduction funds = productionService.getFunds(prodCode);
        display(funds);


        FundsProductionV2 fundsV2 = productionService.getFundsV2(prodCode);
        display(fundsV2);

        String fundProdCode = productionService.getFundProdCode("000509", "JM10101");
        display(fundProdCode);

        Production production = productionService.getProduction(prodCode);
        ProductionChannelAttributes productionChannelAttributes = productionWrapService.getProductionChannelAttributes(production);
        display(productionChannelAttributes);

    }

    void test1() {
        Production production = productionService.getProduction(prodCode);
        display(production);

        display(production.getCurrentDynamicInfo());

        ListWrapper<ProductionBizInfo> bizs = productionService.getBizs(prodCode);
        display(bizs);

        ProductionTimeAttributes timeAttributes = productionWrapService.getProductionTimeAttributes(production, false);
        display(timeAttributes);
        ZiGuanTime ziGuanPeriod = productionWrapService.getZiGuanPeriod(prodCode, new Date());
        display(ziGuanPeriod);
    }

    void test5() {
        String channelProdCode = "xm_ayb005";
        String providerCode = "HKL";
        InterestRateImportRequest req = new InterestRateImportRequest();
        req.setChannelProdCode(channelProdCode);
        req.setProviderCode(providerCode);
        req.setYearYield(new BigDecimal(4.05));
        BaseResponse baseResponse = interestRateService.importInterestRate(req);
        display(baseResponse);
    }
}